/**
 * Mock 数据文件
 * 
 * 格式: { 'method:url': mockResponse }
 * 
 * 例如: 
 * - 'get:users': 用户列表
 * - 'get:users/:id': 单个用户
 * - 'post:users': 创建用户
 */

const mockData = {
  // 用户相关
  'get:users': {
    code: 200,
    message: 'success',
    data: {
      list: Array.from({ length: 10 }, (_, i) => ({
        id: i + 1,
        username: `user${i + 1}`,
        name: `用户${i + 1}`,
        email: `user${i + 1}@example.com`,
        role: i % 3 === 0 ? 'admin' : 'user',
        status: i % 5 === 0 ? 0 : 1,
        createTime: new Date(Date.now() - i * 86400000).toISOString()
      })),
      total: 100,
      page: 1,
      limit: 10
    }
  },
  
  'get:users/:id': {
    code: 200,
    message: 'success',
    data: {
      id: 1,
      username: 'admin',
      name: '管理员',
      email: 'admin@example.com',
      role: 'admin',
      status: 1,
      permissions: ['dashboard', 'user', 'product', 'order'],
      createTime: '2023-01-01T00:00:00Z',
      updateTime: '2023-06-15T08:30:00Z'
    }
  },
  
  'post:users': {
    code: 200,
    message: '创建用户成功',
    data: { id: 11 }
  },
  
  'post:users/:id': {
    code: 200,
    message: '更新用户成功',
    data: null
  },

  'post:users/:id/delete': {
    code: 200,
    message: '删除用户成功',
    data: null
  },
  
  // 商品相关
  'get:products': {
    code: 200,
    message: 'success',
    data: {
      list: Array.from({ length: 10 }, (_, i) => ({
        id: i + 1,
        name: `商品${i + 1}`,
        category: i % 3 === 0 ? '电子产品' : i % 3 === 1 ? '家居用品' : '服装',
        price: Math.floor(100 + Math.random() * 900) / 100,
        stock: Math.floor(Math.random() * 1000),
        status: i % 4 === 0 ? 0 : 1,
        createTime: new Date(Date.now() - i * 86400000).toISOString()
      })),
      total: 100,
      page: 1,
      limit: 10
    }
  },
  
  'get:products/:id': {
    code: 200,
    message: 'success',
    data: {
      id: 1,
      name: '示例商品',
      category: '电子产品',
      description: '这是一个示例商品的详细描述...',
      price: 399.99,
      stock: 200,
      status: 1,
      images: [
        'https://example.com/images/product1-1.jpg',
        'https://example.com/images/product1-2.jpg'
      ],
      attributes: [
        { name: '颜色', value: '黑色' },
        { name: '尺寸', value: '中' }
      ],
      createTime: '2023-03-15T10:30:00Z',
      updateTime: '2023-05-20T14:45:00Z'
    }
  },
  
  // 订单相关
  'get:orders': {
    code: 200,
    message: 'success',
    data: {
      list: Array.from({ length: 10 }, (_, i) => ({
        id: `ORD${String(i + 10001).padStart(6, '0')}`,
        userId: i % 5 + 1,
        username: `user${i % 5 + 1}`,
        status: i % 5,
        totalAmount: Math.floor(100 + Math.random() * 900) / 100,
        payTime: i % 5 === 0 ? null : new Date(Date.now() - i * 86400000).toISOString(),
        createTime: new Date(Date.now() - i * 86400000 - 3600000).toISOString()
      })),
      total: 100,
      page: 1,
      limit: 10
    }
  },
  
  'get:orders/:id': {
    code: 200,
    message: 'success',
    data: {
      id: 'ORD010001',
      userId: 1,
      username: 'user1',
      status: 2,
      totalAmount: 699.98,
      items: [
        {
          productId: 1,
          productName: '示例商品1',
          price: 399.99,
          quantity: 1,
          subtotal: 399.99
        },
        {
          productId: 2,
          productName: '示例商品2',
          price: 299.99,
          quantity: 1,
          subtotal: 299.99
        }
      ],
      address: {
        name: '张三',
        phone: '13800138000',
        province: '广东省',
        city: '深圳市',
        district: '南山区',
        detail: '科技园南路XX号'
      },
      payTime: '2023-06-15T08:30:00Z',
      shipTime: '2023-06-16T10:20:00Z',
      createTime: '2023-06-15T08:20:00Z'
    }
  },
  
  // 统计相关
  'get:stats/dashboard': {
    code: 200,
    message: 'success',
    data: {
      totalUsers: 1250,
      totalProducts: 380,
      totalOrders: 2150,
      totalSales: 125680.50,
      newUsers: 28,
      newOrders: 35,
      recentSales: [
        { date: '2023-06-14', sales: 5280.50 },
        { date: '2023-06-15', sales: 6320.80 },
        { date: '2023-06-16', sales: 4890.30 },
        { date: '2023-06-17', sales: 5680.20 },
        { date: '2023-06-18', sales: 7520.90 },
        { date: '2023-06-19', sales: 6720.40 },
        { date: '2023-06-20', sales: 5980.60 }
      ]
    }
  },
  
  // 系统相关
  'get:system/config': {
    code: 200,
    message: 'success',
    data: {
      siteName: '管理系统',
      logo: 'https://example.com/logo.png',
      theme: 'light',
      uploadSizeLimit: 10,
      allowedFileTypes: ['jpg', 'jpeg', 'png', 'gif', 'pdf', 'doc', 'docx', 'xls', 'xlsx']
    }
  },
  
  // 通用相关
  'get:regions': {
    code: 200,
    message: 'success',
    data: [
      {
        code: '110000',
        name: '北京市',
        children: [
          {
            code: '110100',
            name: '北京市',
            children: [
              { code: '110101', name: '东城区' },
              { code: '110102', name: '西城区' }
            ]
          }
        ]
      },
      {
        code: '440000',
        name: '广东省',
        children: [
          {
            code: '440300',
            name: '深圳市',
            children: [
              { code: '440303', name: '罗湖区' },
              { code: '440304', name: '福田区' },
              { code: '440305', name: '南山区' }
            ]
          }
        ]
      }
    ]
  }
};

export default mockData; 